<?php
/*
*/
//
function getAllStatistics(){
    global $db;
    $rs= $db->query_first("SELECT * FROM statistics");
    return $rs;
}
function countProperty()
{
    global $db;
    $num= mysql_fetch_row($db->query("SELECT count(*) FROM property WHERE status<>'draft'"));    
    return $num[0];
}
function countNews()
{
    global $db;
    $num= mysql_fetch_row($db->query("SELECT count(*) FROM news WHERE active='yes'"));
   return $num[0];
}
function countProject()
{
    global $db;
    $num= mysql_fetch_row($db->query("SELECT count(*) FROM projects "));
    return $num[0];
}
function countDoc()
{
    global $db;
    $num= mysql_fetch_row($db->query("SELECT count(*) FROM document"));
    return $num[0];
}
function countMember()
{
    global $db;
    $num= mysql_fetch_row($db->query("SELECT count(*) FROM members WHERE status='yes' AND username <>'administrator'"));
    return $num[0];
}
function countAdmin()
{
    global $db;
    $num= mysql_fetch_row($db->query("SELECT count(*) FROM admin WHERE active='yes' AND username <>'hiddenadmin' AND username <>'administrator'"));
     return $num[0];
}
function runStatistic()
{
    global $db;
    $data=array();
    $data["count_property"]=countProperty();
    $data["count_news"]=countNews();
    $data["count_project"]=countProject();
    $data["count_doc"]=countDoc();
    $data["count_members"]=countMember();
    $data["count_admin"]=countAdmin();
    $db->exec_update("statistics",$data,"id=1");
  
}
?>